import { request } from "@/utils/service"
import type * as Users from "./types"

/** 增 */
export function createUsersApi(data: Users.CreateOrUpdateUsersRequestData) {
  return request({
    url: "users",
    method: "post",
    data
  })
}

/** 删 */
export function deleteUsersApi(id: string) {
  return request({
    url: `users/${id}`,
    method: "delete"
  })
}

/** 改 */
export function updateUsersApi(data: Users.CreateOrUpdateUsersRequestData) {
  return request({
    url: "users/" + data.id,
    method: "put",
    data
  })
}

/** 查 */
export function getUsersApi(params: Users.GetUsersRequestData) {
  return request<Users.GetUsersResponseData>({
    url: "users",
    method: "get",
    params
  })
}

/** 查详情 */
export function getUsersDetailApi(id: string) {
  return request<Users.GetNewResponeseDetailData>({
    url: `users/${id}`,
    method: "get"
  })
}
